n=int(input())
d=int(input())

A=[[-1 for i in range(d+5)] for i in range(d+5)]

for i in range(1,d+1):
    for j in range(1,d+1):
        A[i][j]=0

i=1
j=1
step=0

while step<d*d:
    while step<d*d and A[i][j]==0:
        A[i][j]=step%n+1
        j+=1
        step+=1
    j-=1
    i+=1
    
    while step<d*d and A[i][j]==0:
        A[i][j]=step%n+1
        i+=1
        step+=1
    i-=1
    j-=1
    
    while step<d*d and A[i][j]==0:
        A[i][j]=step%n+1
        j-=1
        step+=1
    j+=1
    i-=1
    
    while step<d*d and A[i][j]==0:
        A[i][j]=step%n+1
        i-=1
        step+=1
    i+=1
    j+=1


for i in range(1,d+1):
    for j in range(1,d+1):
        if j==d:
            print(A[i][j])
        else:
            print(A[i][j],end=' ')